import random
from tkinter import *
 
class Application(Frame):
    def __init__(self, master):
        
        super(Application, self).__init__(master)
        self.grid()
        self.create_widgets()
 
    def create_widgets(self):
       
        Label(self,
              text = "Hellooo !! @_@"
              ).grid(row = 0, column = 0, columnspan = 2, sticky = W)
 
        
        Label(self,
              text = "Type a number"
              ).grid(row = 1, column = 0, sticky = W)
 
        self.number_ent = Entry(self)
        self.number_ent.grid(row = 1, column = 1, sticky = W)
 
        
       
        Button(self,
               text = "Take a guess...",
               command = self.guess
               ).grid(row = 2, column = 0, sticky = W)
 
        self.answer = Text(self, width = 75, height = 10, wrap = WORD)
        self.answer.grid(row = 3, column = 0, columnspan = 4)
 
 
 
    def guess(self):
        
        the_number = random.randint(1, 128)
        guess_num = self.number_ent.get()
 
        if int(guess_num) > the_number:
            xxx = "Загаданное число больше"
        elif int(guess_num) < the_number:
            xxx = "Загаданное число меньше"
        elif int(guess_num) == the_number:
            xxx = "Вы угадали"
 
        self.answer.delete(0.0, END)
        self.answer.insert(0.0, xxx)
 
root = Tk()
root.title("Задание 27.03.2024")
app = Application(root)
root.mainloop()
